package host.skiree;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class b {
	public static String a(String paramString1, String paramString2, String paramString3) {
		try {
			SecretKeySpec secretKeySpec = new SecretKeySpec(paramString1.getBytes(), "AES");
			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			cipher.init(2, secretKeySpec, new IvParameterSpec(paramString3.getBytes()));
			return new String(cipher.doFinal(Base64.decode(paramString2, 0)));
		} catch (Exception exception) {
			exception.printStackTrace();
			return "";
		}
	}

	public static String b(String paramString1, String paramString2, String paramString3) {
		try {
			Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
			cipher.init(1, new SecretKeySpec(paramString1.getBytes(), "AES"), new IvParameterSpec(paramString3.getBytes()));
			return Base64.encodeToString(cipher.doFinal(paramString2.getBytes(StandardCharsets.UTF_8)), 0);
		} catch (Exception exception) {
			exception.printStackTrace();
			return "";
		}
	}

	public static String c(String paramString) {
		try {
			byte[] arrayOfByte = MessageDigest.getInstance("SHA1").digest(paramString.getBytes());
			StringBuilder stringBuilder = new StringBuilder();
			int j = arrayOfByte.length;
			for (int i = 0; i < j; i++)
				stringBuilder.append(Integer.toString((arrayOfByte[i] & 0xFF) + 256, 16).substring(1));
			return stringBuilder.toString();
		} catch (Exception exception) {
			exception.printStackTrace();
			return "";
		}
	}

	private static MessageDigest e(String paramString) {
		try {
			return MessageDigest.getInstance(paramString);
		} catch (NoSuchAlgorithmException noSuchAlgorithmException) {
			throw new IllegalArgumentException(noSuchAlgorithmException);
		}
	}

	private static byte[] a(String paramString, Charset paramCharset) { return (paramString == null) ? null : paramString.getBytes(paramCharset); }

	public static byte[] b(String paramString) { return a(paramString, StandardCharsets.UTF_8); }


	public static class a {
		private static MessageDigest a() { return b.e("MD5"); }

		public static byte[] b(String param1String) { return c(b.b(param1String)); }

		public static byte[] c(byte[] param1ArrayOfbyte) { return (param1ArrayOfbyte == null) ? null : a().digest(param1ArrayOfbyte); }

		public static String d(String param1String) { return a1.e(b(param1String)); }
	}

}
